<?
if (!$_GET['mois_ouverture'])
{$_SESSION['mois_ouverture']=date("m");}

print mklink_simple("pop.form.todo_and_buy.php?new=1", 470, 550, 20, 20, "saisietodoandbuy")."<img  src=\"../images/todo64.gif\"  border=\"0\" Title=\"Saisir heures\" alt=\"Saisir heures\"></a>";
?>
<style type="text/css">
<!--
.Style1 {font-size: 16px}
-->
</style>




<?


function liste($l, $db)
{
$sql_todo[1]="SELECT * FROM todo_and_buy WHERE etat<100 AND type='todo'  ORDER BY niveau DESC, si_echeance desc, echeance";
$title[1]="ToDo";
$sql_todo[2]="SELECT * FROM todo_and_buy WHERE etat<100 AND type='tobuy' ORDER BY niveau DESC, si_echeance desc, echeance";
$title[2]="ToBuy";
$ilya14jours=date("Y-m-d H:i:s",mktime(0,0,0,date("m"),date("d")-14,date("Y")));
$sql_todo[3]="SELECT * FROM todo_and_buy WHERE etat>99 AND type='todo' AND date_modif > '$ilya14jours' ORDER BY niveau DESC, si_echeance desc, echeance";
$title[3]="ToDo terminé";
$sql_todo[4]="SELECT * FROM todo_and_buy WHERE etat>99 AND type='tobuy'  ORDER BY niveau DESC, si_echeance desc, echeance";
$title[4]="ToBuy terminé";

print "<table border=\"0\">";
print "<tr align=\"center\">
  <td colspan=\"2\"><span class=\"Style1\">".$title[$l]."</span></td>
</tr>";
$limit=0;
$i=1;
//$sql_todo="SELECT * FROM todo_and_buy WHERE etat<100  ORDER BY niveau DESC, si_echeance, echeance";
$res_todo=mysql_query($sql_todo[$l],$db);
while($ligne_todo=mysql_fetch_object($res_todo))
	{
	//admin
	$sql_admin="SELECT * FROM admin WHERE id='$ligne_todo->id_admin'";
	$res_admin=mysql_query($sql_admin,$db);
	$ligne_admin=mysql_fetch_object($res_admin);
	//admin modif
	$sql_admin="SELECT * FROM admin WHERE id='$ligne_todo->id_admin_modif'";
	$res_admin=mysql_query($sql_admin,$db);
	$ligne_admin_modif=mysql_fetch_object($res_admin);
	
	$class="";
	$i++;
	//$i=1;
	if ($i/2 == round($i/2,0)) {$tbl_color="#EEEEEE";}
	else {$tbl_color="#CCCCCC";}
	if ($ligne_todo->si_echeance)
		{
		$joliedate=format_datetime($ligne_todo->echeance,"");
		//aujourd'hui
		if ($ligne_todo->si_echeance && substr($ligne_todo->echeance,0,10)==date("Y-m-d"))
			{$joliedate="aujourd'hui à ".substr($ligne_todo->echeance,-8,5);}
		//en retard
		if ($ligne_todo->si_echeance && $ligne_todo->echeance<date("Y-m-d H:i:s") && $ligne_todo->etat<100)
			{$joliedate="<font color=red>".$joliedate."</font>";}
		}
	else
		{
		$joliedate="n/a";
		}
	if ($ligne_todo->niveau==0) {$niveau_pic="actg_15.gif"; $niveau_name="BAS";}
	elseif ($ligne_todo->niveau==1) {$niveau_pic="acto_15.gif"; $niveau_name="NORMAL";}
	else  {$niveau_pic="actr_15.gif"; $niveau_name="HAUT";}
	$ligne_todo->comment=str_replace("\n", "\n<br/>\n", $ligne_todo->comment);
	
	$alt="niveau: $niveau_name\nAjouté: ".format_datetime($ligne_todo->date_ajout,"")." $ligne_admin->prenom\nModifié: ".format_datetime($ligne_todo->date_modif,"")." $ligne_admin_modif->prenom";
	print "
	<tr valign=top bgcolor=\"$tbl_color\" >
	
	<td class=\"$class\" width=\"60\"><b>$ligne_todo->titre</b></td>
	<td class=$class>$ligne_todo->comment</td></tr><tr bgcolor=\"$tbl_color\"  >
	<td bgcolor=FFFFFF><img src=\"../images/$niveau_pic\" alt=\"$alt\" Title=\"$alt\"> ".mklink_simple("pop.form.todo_and_buy.php?id_todo_and_buy=$ligne_todo->id", 470, 550, 20, 20, "saisietodoandbuy")."<img src=\"../images/mini_$ligne_todo->type.gif\" border=0 ></a>
	</td>
	<td align=right >échéance: $joliedate ".loading_bar($ligne_todo->etat,"../images")."</td>
	</tr>
	<tr height=5><td colspan=2 bgcolor=111111></td></tr>";
	}
	print "</table>";
	}
	
	

?>
<table width="780"  border="0">
  <tr align="left" valign="top">
    <td width="385"><? liste(1, $db); ?></td>
    <td width="385"><? liste(2, $db); ?></td>
  </tr>
  <tr align="left" valign="top">
    <td width="385"><? liste(3, $db); ?></td>
    <td width="385"><? liste(4, $db); ?></td>
  </tr>
</table>
